<link href="<?php echo base_url(); ?>public/css/stiloquejassuge.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function prueba(){
  var anos; 
  var num = $("#fecha2").val().substring(0,2);
  return anos =  $("#fecha2").val().substring(6,10)+','+num+','+$("#fecha2").val().substring(3,5);	
} 

function prueba3(){
	
  var anos; 
  var num = $("#cfecha2").val().substring(0,2);
  return anos =  $("#cfecha2").val().substring(6,10)+','+num+','+$("#cfecha2").val().substring(3,5);
   
} 

function prueba2(){
var anos; 
var num = $("#fechas").val().substring(0,2);
return anos =  $("#fechas").val().substring(6,10)+','+num+','+$("#fechas").val().substring(3,5);
   	
} 
</script>
<div id="error"></div>
<script language="javascript">
    // apply filters
        var applyFilter = jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/transaccionentrada/data/',
            mtype: 'POST',
            datatype: 'json',
            colNames:['ID','Referencia','Fecha Reg','Servicios','Proximo Cont.','Tipo Entrada','Dias I.','Dias D.','Contactos','IMP','KPIs'],
         colModel :[
                {name:'IdTransaccion', index:'IdTransaccion', width:2,hidden:true},
                {name:'referencia', index:'referencia', width:40},
                {name:'DateSolicitud', index:'DateSolicitud', width:25},
                {name:'idServicios', index:'IdServicios', width:28},
                {name:'ProximoContacto', index:'ProximoContacto', width:28},
                {name:'entrada', index:'idTipoEntrada', width:27},
                {name:'cantida', index:'idTipoEntrada', width:15},
                {name:'diase', index:'ProximoContacto', width:15},
                {name:'contacto', index:'Contacto', width:30},
                {name:'estrella', index:'est', width:15},
                {name:'image', index:'ProximoContacto', width:15}],
               
             
            pager: jQuery('#pager'),
            hiddengrid: true,
            sortname: 'IdTransaccion',
            rowNum:500,
            rowList:[500,400,300],
            sortorder: "DESC",
            height: '100%',
            width: '630',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: false,
            onSelectRow: function(ids) 
            {
            	if(ids != null) 
            	{
            		var rec = jQuery("#list").getRowData(ids);
            		lol=ids;
            		
            		jQuery("#list_etapas").setGridParam({url : _site_url + '/transaccionentrada/data2', page : 1, mtype:'POST',postData:{iddetalle:rec.IdTransaccion}}).setCaption("Dias restante para la proxima cita: "+dias(rec.ProximoContacto)).trigger('reloadGrid');
            	     
            	}
            	
            },
            adjacents: 4,
            jsonReader: { repeatitems : false, id_etapa: "0" }
        })
        
        
        .navGrid('#pager',{edit:false,add:false,del:false,search:false
          })
        
          
        .navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:
        function()
        { 
         jQuery("#list").setColumns();
        } })
        
        .navButtonAdd('#pager',{caption:"Agregar", buttonimg: _base_url + "public/images/new.png", onClickButton:
        function(){ window.location = _site_url + "/transaccionentrada/add"; } })
        
        .navButtonAdd('#pager',{caption:"Editar", buttonimg: _base_url + "public/images/edit.png", onClickButton:
        function(){ var id = jQuery('#list').getGridParam('selarrrow');
        var id = jQuery('#list').getGridParam('selarrrow');  
        var id=lol;  
        if (id.length > 0) 
        {
          
                var ret = jQuery("#list").getRowData(id);
                window.location = _site_url + '/transaccionentrada/edit/' + ret.IdTransaccion;
           
        } else { jAlert('Debe seleccionar al menos u status'); }
        return false; } })
        
         
        .navButtonAdd('#pager',{caption:"Historial", buttonimg: _base_url +  "public/css/jqgrid/flex/images/tab_close-on.gif", onClickButton:
        function(){ var id = jQuery('#list').getGridParam('selarrrow');
        var id = jQuery('#list').getGridParam('selarrrow');  
        var id=lol;  
        if (id.length > 0) 
        {
          
                var ret = jQuery("#list").getRowData(id);
              
                window.location = _site_url + '/transaccionentrada/historial/' + ret.IdTransaccion;
          
        } else { jAlert('Debe seleccionar al menos u status'); }
        return false; } })
          
        $('#apply_filter').bind('click', applyFilter);
        
    	});

        var flAuto = true;
        var timeoutHnd; 

        function doSearch(ev)
        { 
              if(!flAuto) return; 
              // var elem = ev.target||ev.srcElement; 
              if(timeoutHnd) 
                  clearTimeout(timeoutHnd); 
                  timeoutHnd = setTimeout(gridReload,500); 
        } 
         
        function enableAutosubmit(state)
        { 
              flAuto = state; 
              jQuery("#submitButton").attr("disabled",state); 
        }
        
        function gridReload()
        { 
       	     
                 var ct_mask = jQuery("#search_ct").val();
                 var re_mask = jQuery("#search_re").val(); 
                 var se_mask = jQuery("#search_se").val(); 

                 var array_search = re_mask+'-'+ct_mask+'-'+se_mask;
              
                 jQuery("#list").setGridParam({url :'<?php echo site_url() ?>/transaccionentrada/data/'+array_search, page : 1}).trigger('reloadGrid'); 
        }

        
    applyFilter.filterToolbar();
    
    function getCheckedValue(radioObj) 
    {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
 
 function dias(date)
 {
 	var time=new Date(); 
 	
    var d = Date.UTC(date.substring(6,10),date.substring(0,2),date.substring(3,5));
    var mes = parseInt(time.getMonth());
    var ds = Date.UTC(time.getFullYear(),mes+1,time.getDate());

    var dias = d - ds;

     dias = dias/1000;
     dias = dias/60;
     dias = dias/60;
     dias = dias/24;

    return dias;
 }

 function mostrar(pagina){

		var opciones = "width = 400, height=200, top=100, left=140";
	    window.open("<?php echo site_url() ?>"+pagina,"Detalle",opciones);
 }
  
</script>

<?php
$entrada = $this->mtipoentrada->LoadEstatus();
$servicios = $this->mservicios->Loadservicios();
?>

<div class="table_container">
<a href="<?php echo site_url();?>/graficoventasservicios"><font size = "3%" >Ventas</font></a> |
<a href="<?php echo site_url();?>/graficoseguimientosventas"><font size = "3%" >Seguimientos Ventas</font></a> |
<a href="<?php echo site_url();?>/indicadoresseguimientoci"><font size = "3%" >Indicadores CI </font></a>
<div>
	<table>
	
		<!-- Esta es la parte de quejas y Sugerencias-->

<?php if(@$quejasSug != false):?>
<table>
<tr>
   <td>
       <div id="titulo" class="errores">Quejas y Sugerencias</div>
   </td>
</tr> 

<tr>
   <td>
     <div id="errorLeft">
        <table class = "Mtabla">
           <tr>
               <th colspan="8"><b></b></th>
           </tr>
          
           <tr style="background: #E6E6E6;">
             <td style="width: 20px; "><strong>ID</strong></td>
             <td style="width: 48px;"><strong>Fecha</strong></td>
             <td style="width: 48px;"><strong>Referencia</strong></td>
             <td style="width: 48px;"><strong>Clasificacion</strong></td>
             <td style="width: 48px;"><strong>Detalle</strong></td>
             <td style="width: 48px;"><strong>Mail</strong></td>
             <td style="width: 48px;"><strong>Contacto</strong></td>
             <td style="width: 48px;"><strong>Telefono</strong></td>
           </tr> 
           
            <?php 
            $i = 1; 
            foreach ($quejasSug as $k):
            
               $enlace2 =  '/registroeqs/detallePopUps/'.$k[0];
            
             
             ?>
            <tr>
               <td><?php echo $i++;?></td>
               <td><?php echo $k[1];?></td>
               <td><?php echo $k[2];?></td>
               <td><?php echo $k[3];?></td>
               <td><a onclick="mostrar('<?php echo $enlace2?>')"><font>Ver Detalle</font></a></td>
               <td><?php echo $k[5];?></td>
               <td><?php echo $k[6];?></td>
               <td><?php echo $k[7];?></td>
            </tr> 
           <?php endforeach;?> 
        </table>       
      <?php endif;?>
	</table>
</div>

<table>
<tr>
  
   <td><div id="titulo">Registro De Inbound</div></td>
   
</tr>

    <tr>
       <td style="background: #D9E6F0;border: 1px solid #C3AA64; height: 23px">&nbsp;<b>Referencia:<b/> <input type='text' background='#ff22ff' id='search_re' onkeydown='doSearch(arguments[0]||event)' style='height:13px;font-size:2;color:#ff00ff;'size='10'/>&nbsp;&nbsp;&nbsp;<b>Contactos:<b/> <input type='text' background='#ff22ff' id='search_ct' onkeydown='doSearch(arguments[0]||event)' style='height:13px;font-size:2;color:#ff00ff;' size='10'/>&nbsp;&nbsp;&nbsp;&nbsp;<b>Servicios:<b/><select id='search_se' onChange='doSearch(arguments[0]||event)'><option></option> <?php foreach ($servicios as $k): echo '<option value="'.$k->getIdServicio().'">'.$k->getNombreServicio().'</option>'; endforeach;?></select>
       </td>
    </tr>
<tr>
<td>
    <table id="list" class="scroll"></table>
    <div id="pager" class="scroll" style="text-align:center;"></div>
</td>
 </tr>
<?php $this->load->view('detalle_registro');?>
</table>
</div>

